package com.cn.wanxi.rabbitmq.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @ClassName HRMQListener
 * @Description TODO
 * @Author JiJiang
 * @Date 2022/9/28 16:57
 * @Version 1.0
 */

@Slf4j
@Component
public class HRMQListener {


    //    @RabbitHandler
//    @RabbitListener(queues = "wx_hr")//从哪些队列里取消息，可以写多个，写的是队列名。
//    @RabbitListener(queuesToDeclare = @Queue("wx_hr"))// 这个也可以，只是这个传的是Queue对象。
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "wx_hr") //指定该监听器绑定的队列名
            , exchange = @Exchange(name = "wx.in_home.topic", type = ExchangeTypes.TOPIC)
            , key = {"wx.#"}
    ))
    public void receive(String message) {
        System.out.println(message);
        log.info("HR收到消息，消息内容是: {}", message);
    }

}
